#!/usr/bin/python

import gzip,bz2

srcfile='dictG'

f=open(srcfile,'rb')
t=f.read()
f.close()
print 'filesize:',len(t),'byte'

# zip by gzip:
f=gzip.open(srcfile+'.gz','wb')
f.write(t);f.close()
f=open(srcfile+'.gz','rb')
f.read()
print 'filesize: %d byte[by gzip],rate=%f' % (f.tell(),f.tell()*1.0/len(t))
f.close()

# zip by bz2:
f=open(srcfile+'.bz2','wb')
c=bz2.compress(t)
f.write(c)
f.close()
print 'filesize: %d byte [by bz2],rate=%f' % (len(c),len(c)*1.0/len(t))

raw_input('Press enter to exit.')